package com.spider.im.user.controller;


import com.spider.im.common.aspect.RespResult;
import com.spider.im.common.security.SecurityUtils;
import com.spider.im.login.resp.LoginUser;
import com.spider.im.user.req.UserReq;
import com.spider.im.user.resp.UserResp;
import com.spider.im.user.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.apache.catalina.security.SecurityUtil;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author joy
 * @since 2025-04-22
 */
@RestController
@RequestMapping("/api/user")
@Tag(name = "UserController",  description = "用户管理")
public class UserController {

    @Resource
    private UserService userService;
    /**
     * 新增用户接口
     */
    @Operation(summary = "用户注册")
    @PostMapping("/register")
    public RespResult<UserResp> register(@RequestBody UserReq userReq) {

        return RespResult.success(userService.register(userReq));
    }

    /**
     * 测试
     */
    @Operation(summary = "获取用户")
    @PostMapping("/getUser")
    public RespResult<LoginUser> getUser() {
        LoginUser loginUser = SecurityUtils.getLoginUser();

        return RespResult.success(loginUser);
    }

    /**
     * 测试
     */
    @Operation(summary = "测试")
    @GetMapping("/test")
    public RespResult<String> testGet() {

        return RespResult.success("测试成功GEt ");
    }
}

